﻿#include "multineedlerotary.h"

MultiNeedleRotary::MultiNeedleRotary()
{
    //添加各种参数到列表中
    initRootParasList();
    initRootHMIConfigurationList(m_allParasList);//超级用户界面配置
    initPatternsParasList();
    initSoftwareParasList(m_allParasList);
    initTimeParasList(m_allParasList);
    initMcParasList();
    initWkParasList();

    //初始化控制动作列表
    initOutCtrlList();

    //初始化快捷功能列表
    initShortCutList();

    //初始化辅助功能列表
    initAssistList();

    //初始化花样设置功能列表
    initPatternSetList();

    //参数分类功能
    initParaSetList();

    //初始化传感器列表
    initSensorList();

    //初始化错误代码和状态列表
    initErrorCodeAndStateList();

    //初始化九宫格
    initNinebtn1234();

    //加载右上角信息
    initFileInfoLabel();
}

MultiNeedleRotary::~MultiNeedleRotary()
{

}

void MultiNeedleRotary::initNinebtn1234()
{
    m_nineBtn.insert(1,NineItem(FUN_ALLTOZERO,"buttonFrameZero"));
    m_nineBtn.insert(2,NineItem(FUN_PATTERN_PREVIEW,"buttonPatternPreview"));
    m_nineBtn.insert(3,NineItem(FUN_SHUTTLE_REFUELING,"buttonShuttleRef"));
    m_nineBtn.insert(4,NineItem(FUN_NEEDLE_REFUELING,"buttonNeedleRef"));
}

void MultiNeedleRotary::initPatternsParasList()
{
    int index = 0; //按顺序排列，想要更改顺序只需要修改代码位置
    //花样参数-花样设置参数-缩放x；单位：毫米 ，范围0-20000，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_SCANX, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Width"),//宽度
                                        5000, 0, 20000, 0, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));

    //花样参数-花样设置参数-缩放y；单位：毫米 ，范围0-20000，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_SCANY, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Height"),//高度
                                        5000, 0, 20000, 0, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));

    //花样参数-花样设置参数-针步大小；单位：毫米 ，范围20-80，默认20
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_SETSTEPSIZE, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Step size"),//针步大小
                                        20, 20, 80, 20, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));

    //    //花样参数-花样设置参数-角度修正量；单位：毫米 ，范围0-200，默认0
    //    m_allParasList.append(makeAParaItem(0,
    //                                        PARA_TYPE_PATTERN,
    //                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
    //                                        SET_ANGLECORROFFSET, 0, 0, PARA_VALUE_TYPE_INT,
    //                                        tr("Angle correction offset"),//角度修正量
    //                                        0, 0, 200, 0, 1, tr("mm"), tr(""),
    //                                        tr(""),
    //                                        0, 0, index++, operate));
    //花样参数-花样设置参数-角度修正x正；单位：毫米 ，范围0-200，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_ANGLECORRPOSX, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Angle correction x positive"),//角度修正x正
                                        0, 0, 200, 0, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));

    //花样参数-花样设置参数-角度修正x负；单位：毫米 ，范围0-200，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_ANGLECORRNEGX, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Angle correction x negative"),//角度修正x负
                                        0, 0, 200, 0, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));

    //花样参数-花样设置参数-角度修正y正；单位：毫米 ，范围0-200，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_ANGLECORRPOSY, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Angle correction y positive"),//角度修正y正
                                        0, 0, 200, 0, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));

    //花样参数-花样设置参数-角度修正y负；单位：毫米 ，范围0-200，默认0
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI,
                                        SET_ANGLECORRNEGY, 0, 0, PARA_VALUE_TYPE_INT,
                                        tr("Angle correction y negative"),//角度修正y负
                                        0, 0, 200, 0, 1, tr("mm"), tr(""),
                                        tr(""),
                                        0, 0, index++, operate));
    //是否启用 拐角增加针步
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI ,
                                        SET_CORNERNEEDLE, 0, 0, PARA_VALUE_TYPE_SW,
                                        tr("Add needle steps at corners"),
                                        1, 0, 1, 1, 0, "", tr(""),
                                        tr(""), 0, 0,0x0008, operate));
    //是否启用 拐角分割针步
    m_allParasList.append(makeAParaItem(0,
                                        PARA_TYPE_PATTERN,
                                        PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI ,
                                        SET_CUTNEEDLE, 0, 0, PARA_VALUE_TYPE_SW,
                                        tr("Corner segmentation needle step"),
                                        1, 0, 1, 1, 0, "", tr(""),
                                        tr(""), 0, 0,0x0008, operate));
    {
        //花样预览-主轴类型
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_PATTERN,
                                            PATTERN_PREVIEW ,
                                            PV_SPINDLE_TYPE, 0, 0, PARA_VALUE_TYPE_LIST,
                                            tr("Spindle Type"),//主轴类型
                                            0, 0, 1, 0, 0, tr(""), tr(""),
                                            //0, 单排; 1, 双排; 默认0
                                            tr("Single Row:0;Double Row:1"),
                                            0, 0, 0x0009, operate));
        //花样预览-针间距
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_PATTERN,
                                            PATTERN_PREVIEW ,
                                            PV_NEEDLE_SPACING, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Needle spacing"),//针间距
                                            0, 0, S32_MAX, 1, 0, "", tr(""),
                                            tr(""), 0, 0,0x0010, operate));
        //花样预览-排针间距
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_PATTERN,
                                            PATTERN_PREVIEW ,
                                            PV_SPACING_BETWEEN_NEEDLE_ROWS, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Spacing between needle rows"),//排针间距
                                            1, 0, S32_MAX, 1, 0, "", tr(""),
                                            tr(""), 0, 0,0x0011, operate));
        //花样预览-下排机头居中
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_PATTERN,
                                            PATTERN_PREVIEW ,
                                            PV_LOWER_ROW_HEAD_CENTERED, 0, 0, PARA_VALUE_TYPE_SW,
                                            tr("Lower row head centered"),//下排机头居中
                                            1, 0, 1, 1, 0, "", tr(""),
                                            tr(""), 0, 0,0x0012, operate));
    }
}

void MultiNeedleRotary::initMcParasList()
{
    //    QTextCodec *cod = QTextCodec::codecForLocale();


}

void MultiNeedleRotary::initWkParasList()
{
    // QTextCodec *cod = QTextCodec::codecForLocale();
    //速度参数
    {
        // 主轴缝纫工作转速, 范围 1--500,单位r/min,默认 300
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            0, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Sewing main shaft working speed"),// 主轴缝纫工作转速
                                            2000, 1, 3600, 2000, 0, tr("r/min"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // 主轴归零转速, 范围 1--3000，单位r/min，默认 120
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            110, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Main shaft zero reset speed"),//主轴归零转速
                                            120, 1, 3000, 120, 0, tr("r/min"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // 主轴运转转速, 范围 1--3000，单位r/min，默认 300
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            111, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Main shaft running speed"),//主轴运转转速
                                            120, 1, 3000, 120, 0, tr("r/min"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // xy归零运行速度, 范围 1--500，单位mm/s，默认 100
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            101, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("XY zero reset speed"),//xy归零运行速度
                                            100, 1, 500, 100, 0, tr("mm/s"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // xy空走运行速度, 范围 1--1700，单位mm/s，默认 300
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            102, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("XY zero reset speed"),//xy空走运行速度
                                            300, 1, 1700, 300, 0, tr("mm/s"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // xy手动移动速度1, 范围 1--1000，单位mm/s，默认 10
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            105, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("XY manual movement speed 1"),//xy手动移动速度1
                                            10, 1, 1000, 10, 0, tr("mm/s"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // xy手动移动速度2, 范围 1--1000，单位mm/s，默认 100
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            106, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("XY manual movement speed 2"),//xy手动移动速度2
                                            100, 1, 1000, 100, 0, tr("mm/s"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // xy手动移动速度3, 范围 1--1000，单位mm/s，默认 300
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SPEED,
                                            107, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("XY manual movement speed 3"),//xy手动移动速度3
                                            300, 1, 1000, 300, 0, tr("mm/s"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));

        //    // 单排多针旋梭绗缝机慢速速度
        //    m_allParasList.append(makeAParaItem(0,
        //                                        PARA_TYPE_WORK,
        //                                        MC_SORT_SPEED,
        //                                        211, 0, 0, PARA_VALUE_TYPE_INT,
        //                                        tr(""),//
        //                                        300, 1, 1000, 300, 0, tr("mm/s"), tr(""),
        //                                        tr(""), 0, 0, 0x0001, operate));
        //    // 单排多针旋梭绗缝机快速速度
        //    m_allParasList.append(makeAParaItem(0,
        //                                        PARA_TYPE_WORK,
        //                                        MC_SORT_SPEED,
        //                                        212, 0, 0, PARA_VALUE_TYPE_INT,
        //                                        tr(""),//
        //                                        300, 1, 1000, 300, 0, tr("mm/s"), tr(""),
        //                                        tr(""), 0, 0, 0x0001, operate));

    }

    //动作参数
    {
        //起针动作松线允许, 范围0-1，默认0
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            9, 1, 0, PARA_VALUE_TYPE_LIST,
                                            tr("Needle action, thread loosen allowed"),//起针动作松线允许
                                            0, 0, 1, 0, 0, tr(""), tr(""),
                                            tr("Not allow:0;allowed:1"),//不允许:0;允许:1
                                            0, 0, 0x0001, root));
        //加油方式选择, 范围0-3，默认0
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            20, 0, 0, PARA_VALUE_TYPE_LIST,
                                            tr("Oiling mode selection"),//加油方式选择
                                            0, 0, 3, 0, 0, tr(""), tr(""),
                                            //不加油: 0;按时间加油:1;按针数加油:2;持续加油:3
                                            tr("No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3"),
                                            0, 0, 0x0001, operate));
        //加油针数间隔, 范围0-最大，默认10000
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            21, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Oiling interval by needle stitch"),//加油针数间隔
                                            10000, 0, S32_MAX, 10000, 0, tr("Needle"), tr(""),//针
                                            tr(""),
                                            0, 0, 0x0001, operate));
        //加油时间间隔, 范围1-最大，默认1
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            22, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Oiling interval by working time"),//加油时间间隔
                                            1, 1, S32_MAX, 1, 0, tr("s"), tr(""),
                                            tr(""),
                                            0, 0, 0x0001, operate));
        //针加油持续时长, 范围1-最大，默认1
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            23, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Needle Oiling sustained time"),//针加油持续时长
                                            1, 1, S32_MAX, 1, 0, tr("s"), tr(""),
                                            tr(""),
                                            0, 0, 0x0001, operate));
        //梭加油持续时长,(针梭独立加油时有效) 范围0-最大，默认0
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            110, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Shuttle Oiling sustained time"),//梭加油持续时长
                                            0, 0, S32_MAX, 0, 0, tr("s"), tr(""),
                                            tr(""),
                                            0, 0, 0x0001, operate));
        //暂停按钮延时时间, 范围0-最大，默认0
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_ACTION,
                                            210, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Shuttle Oiling sustained time"),//梭加油持续时长
                                            0, 0, S32_MAX, 0, 0, tr("s"), tr(""),
                                            tr(""),
                                            0, 0, 0x0001, operate));
    }

    //设置参数
    {
        // 主轴缝纫工作转速, 范围 1--500,单位r/min,默认 300
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            0, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Sewing main shaft working speed"),// 主轴缝纫工作转速
                                            2000, 1, 3600, 2000, 0, tr("r/min"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // 工作机头选择
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            100, 1, 0, PARA_VALUE_TYPE_INT,
                                            tr("Work head selection 1"),//工作头选择1
                                            1, 0, 1, 1, 0, tr(""), tr(""),
                                            tr("Not allow:0;allowed:1"), 0, 0, 0x0001, operate));
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            100, 2, 0, PARA_VALUE_TYPE_INT,
                                            tr("Work head selection 2"),//工作头选择2
                                            1, 0, 1, 1, 0, tr(""), tr(""),
                                            tr("Not allow:0;allowed:1"), 0, 0, 0x0001, operate));
        // 产量预设
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            33, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Production preset"),// 产量预设
                                            0, 0, S32_MAX, 0, 0, tr(""), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));

        // 断线检测针数; 0, 不检测断线; 其他, 断线信号连续针数，默认3
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            14, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("No. of stitch detect if thread broken"),// 断线检测针数
                                            3, 0, 10, 3, 0, tr("Needle"), tr(""),//针
                                            tr(""), 0, 0, 0x0001, operate));

        // 底线长度, 单位 0.01mm，默认 10000000
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            17, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Bobbin thread length"),// 底线长度
                                            10000000, 0, S32_MAX, 10000000, 2, tr("mm"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
    }

    //检测参数
    {
        // 断线检测针数; 0, 不检测断线; 其他, 断线信号连续针数，默认3
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_DETECT,
                                            14, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("No. of stitch detect if thread broken"),// 断线检测针数
                                            3, 0, 10, 3, 0, tr(""), tr(""),
                                            tr(""), 0, 0, 0x0002, operate));
        // 换梭芯提醒功能, 0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_DETECT,
                                            16, 0, 0, PARA_VALUE_TYPE_LIST,
                                            tr("Bobbin change reminder function"),//换梭芯提醒功能
                                            0, 0, 3, 0, 0, tr(""), tr(""),
                                            //0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0
                                            tr("Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3"), 0, 0, 0x0012, operate));
        // 底线长度, 单位 0.01mm，默认 10000000
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_DETECT,
                                            17, 0, 0, PARA_VALUE_TYPE_INT,
                                            tr("Bobbin thread length"),// 底线长度
                                            10000000, 0, S32_MAX, 10000000, 2, tr("mm"), tr(""),
                                            tr(""), 0, 0, 0x0001, operate));
        // 安全输入允许，位图选择，0, 不允许; 1, 允许;
        // bit0, 光幕;
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            101, 1, 0, PARA_VALUE_TYPE_SW,
                                            tr("Secure input light curtain allows"),//安全输入光幕允许
                                            0, 0, 1, 0, 0, tr(""), tr(""),
                                            tr(""),0, 0, 0x0010, operate));

        // bit1, 气压;
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            101, 2, 0, PARA_VALUE_TYPE_SW,
                                            tr("Safety input pressure allowed"),//安全输入气压允许
                                            0, 0, 1, 0, 0, tr(""), tr(""),
                                            tr(""),0, 0, 0x0010, operate));

        // bit2, 上电信号;
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            101, 3, 0, PARA_VALUE_TYPE_SW,
                                            tr("Safe input power-on signal allowed"),//安全输入上电信号允许
                                            0, 0, 1, 0, 0, tr(""), tr(""),
                                            tr(""),0, 0, 0x0010, operate));

        // bit4, 安全门
        m_allParasList.append(makeAParaItem(0,
                                            PARA_TYPE_WORK,
                                            MC_SORT_SETTING,
                                            101, 4, 0, PARA_VALUE_TYPE_SW,
                                            tr("Safe door allowed"),//安全门允许
                                            0, 0, 1, 0, 0, tr(""), tr(""),
                                            tr(""),0, 0, 0x0010, operate));
    }
}

//电机动作
#define	MT_LM2				0x0013	// 主轴2电机
#define	MT_SPREAD			0x0062	// 展布电机-转动
#define	MT_LAM				0x0050	// 所有主轴电机

void MultiNeedleRotary::initOutCtrlList()
{
    m_allOutCtrlList.clear();
    int showPriority = 1;

    //电机动作
    {
        m_allOutCtrlList.append(creatNoZeroItem(0,showPriority++,tr("X to move motor"),MT_LX));// X向移动电机(使能，失能,正转,反转)
        m_allOutCtrlList.append(creatNoZeroItem(0,showPriority++,tr("Y to move motor"),MT_LY));// Y向移动电机(使能，失能,正转,反转)
        m_allOutCtrlList.append(creatALLItem(0,showPriority++,tr("Spindle motor 1"),MT_LM));// 主轴电机(使能，失能，归零,正转,反转)
        m_allOutCtrlList.append(creatALLItem(0,showPriority++,tr("Spindle motor 2"),MT_LM2));// 主轴2电机(使能，失能，归零,正转,反转)
        m_allOutCtrlList.append(creatALLItem(0,showPriority++,tr("Spreading motor"),MT_SPREAD));// 展布电机(使能，失能，归零,正转,反转)
    }

    {
        m_allOutCtrlList.append(creatReleaseTightenItem(0,showPriority++,tr("Elastic thread"),OT_LOOSE_THREAD));// 松紧线
        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Lower cloth cylinder"),OT_DW_PUSH_CLOTH));// 下压布气缸
        //m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Upper row needle oiling"),OT_UP_NEEDLE_OIL));// 针加油
        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Bottom row needle oiling"),OT_DW_NEEDLE_OIL));// 下针加油
        //m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Upper row shuttle oiling"),OT_UP_HOOK_OIL));// 上梭加油
        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Bottom row shuttle oiling"),OT_DW_HOOK_OIL));// 下梭加油
        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("blow"),OT_SEW_BLOW));// 缝纫吹气
        //        //m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Upper row needle oiling 1"),OT_UP_NEEDLE_OIL));// 上针加油1
        //        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Bottom row needle oiling 1"),OT_DW_NEEDLE_OIL));// 下针加油1
        //        //m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Upper row shuttle oiling 1"),OT_UP_HOOK_OIL));// 上梭加油1
        //        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Bottom row shuttle oiling 1"),OT_DW_HOOK_OIL));// 下梭加油1
        //        //m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Upper row needle oiling 2"),OT_UP_NEEDLE_OIL));// 上针加油2
        //        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Bottom row needle oiling 2"),OT_DW_NEEDLE_OIL));// 下针加油2
        //        //m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Upper row shuttle oiling 2"),OT_UP_HOOK_OIL));// 上梭加油2
        //        m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Bottom row shuttle oiling 2"),OT_DW_HOOK_OIL));// 下梭加油2
    }



    //m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All spindle zero positions"),MT_ALLZ)); // 所有主轴 零位	(归零)
    //m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All Spindle Hook Lines positions"),MT_ALLG));  // 所有主轴 勾线	(归零)
    //m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All spindle jogs positions"),MT_ALLM)); // 所有主轴 点动	(归零)

}

void MultiNeedleRotary::initShortCutList()
{
    m_allShortCutList.clear();
    int index = 1;;

    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Front Back"),"buttonForwardOrBack",FUN_FORWARDORBACK));// 快进快退
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("back Zero Point"),"buttonBackToOrigin",FUN_BACKTOORIGIN));// 回零点
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("StartWork"),"buttonStartWork",FUN_STARTWORK));//启动工作
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("All Zero"),"buttonFrameZero",FUN_ALLTOZERO));//全部归零
    m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Bottom Count Reset"),"buttonShutCount",FUN_COUNTRESET));//底线计数清零
    m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Output Reset"),"buttonFrameZero",FUN_OUTPUTRESET));//产量清零

}

void MultiNeedleRotary::initAssistList()
{
    m_allAssistList.clear();

    m_allAssistList.append(makeAAssistItem(0,0x0001,tr("Signal"),"buttonSensor",ASSIST_SENSOR));//传感器信号
    m_allAssistList.append(makeAAssistItem(0,0x0002,tr("Action"),"buttonControlAction",ASSIST_CONTROLACTION));//控制动作
    m_allAssistList.append(makeAAssistItem(0,0x0003,tr("HMI Upgrade"),"buttonHMIUpgrade",ASSIST_HMIUPGRADE));//界面升级
    m_allAssistList.append(makeAAssistItem(0,0x0004,tr("MC Upgrade"),"buttonMCUpgrade",ASSIST_MCUPGRADE));//主控升级
    m_allAssistList.append(makeAAssistItem(0,0x0006,tr("ParaImport"),"buttonParaImport",ASSIST_PARAIMPORT));//参数导入
    m_allAssistList.append(makeAAssistItem(0,0x0007,tr("ParaExport"),"buttonParaExport",ASSIST_PARAEXPORT));//参数导出
    m_allAssistList.append(makeAAssistItem(0,0x0008,tr("Setting"),"buttonSoftwareSet",ASSIST_SOFTWARESET));//软件设置
    m_allAssistList.append(makeAAssistItem(0,0x0009,tr("Authorize"),"buttonSoftwareAuthor",ASSIST_AUTHORIZATION));//软件授权
    m_allAssistList.append(makeAAssistItem(0,0x000A,tr("Network"),"buttonNetworkManage",ASSIST_NETWORK));//网络管理
    m_allAssistList.append(makeAAssistItem(0,0x000C,tr("Time"),"buttonTimeSet",ASSIST_TIMESET));//时间设置
    m_allAssistList.append(makeAAssistItem(0,0x000F,tr("Version"),"buttonVersionInfo",ASSIST_MCVERSION));//版本信息
    m_allAssistList.append(makeAAssistItem(0,0x0014,tr("Root"),"buttonRoot",ASSIST_ROOT));//超级用户

}

void MultiNeedleRotary::initPatternSetList()
{
    m_allPatternSetList.clear();

    m_allPatternSetList.append(makeAPatternSetItem(0,0x0001,tr("Para"),"buttonPatternPara",PATTERNSET_PATTERNPARA));//花样参数
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0002,tr("Select"),"buttonPatternSelect",PATTERNSET_PATTERNSELECT));//花样选择
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0004,tr("Import"),"buttonPatternImport",PATTERNSET_PATTERNIMPORT));//花样导入
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0005,tr("Export"),"buttonPatternExport",PATTERNSET_PATTERNEXPORT));//花样导出
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0006,tr("Delete"),"buttonPatternDelete",PATTERNSET_PATTERNDELETE));//花样删除
    m_allPatternSetList.append(makeAPatternSetItem(0,0x0007,tr("Preview"),"buttonPatternPreview",PATTERNSET_PATTERNPREVIEW));//花样预览

}

void MultiNeedleRotary::initParaSetList()
{
    m_allParaSetList.clear();

    m_allParaSetList.append(makeAParaSetItem(0,0x0001,tr("OperatPara"),"buttonPositionParas",PARASET_SETTING));//设置参数  //操作参数
    m_allParaSetList.append(makeAParaSetItem(0,0x0002,tr("ActionSet"),"buttonActionParas",PARASET_ACTION));//动作参数   //动作设定
    m_allParaSetList.append(makeAParaSetItem(0,0x0003,tr("SpeedPara"),"buttonSpeedParas",PARASET_SPEED));//速度参数  //速度控制参数
    //m_allParaSetList.append(makeAParaSetItem(0,0x0004,tr("LimitPara"),"buttonDetectParas",PARASET_POSITION));// 位置参数  //限位参数
    m_allParaSetList.append(makeAParaSetItem(0,0x0005,tr("MCPara"),"buttonSettingParas",PARASET_DETECT));//设置参数    //机器参数

}

void MultiNeedleRotary::initSensorList()
{
    QList <SensorItem> sensorList;
    sensorList.clear();

    sensorList.append(makeASensorItem(0x0000, 0, tr("Start button 1")));//启动按钮1
    sensorList.append(makeASensorItem(0x0001, 0, tr("Pause button 1")));//暂停按钮1
    sensorList.append(makeASensorItem(0x0007, 0, tr("Sensor 1 Air Pressure Monitoring")));//气压监测1
    sensorList.append(makeASensorItem(0x0008, 0, tr("Security input 1")));//安全输入1
    sensorList.append(makeASensorItem(0x0008, 1, tr("Security input 2")));//安全输入2
    sensorList.append(makeASensorItem(0x0010, 0, tr("Power-up Signal Type 1")));//加电信号1
    sensorList.append(makeASensorItem(0x0022, 0, tr("X negative limit")));//X限位-
    sensorList.append(makeASensorItem(0x0023, 0, tr("X positive limit")));//X限位+
    sensorList.append(makeASensorItem(0x0080, 0, tr("Sewing machine head 1-needle parking spot")));//缝纫机头1-针停车位
    sensorList.append(makeASensorItem(0x0170, 0, tr("Sewing machine head 1 - surface thread breakage inspection")));//缝纫机头1-面线断检

    //将机型所需的传感器列表替换到传感器整体列表中
    for(int i = 0; i < sensorList.size(); i++)
    {
        int byteaddr = sensorList[i].m_byte_offset;
        int bitaddr = sensorList[i].m_bit_offset;
        QString str = sensorList[i].m_name;
        int type = sensorList[i].m_type;

        int idx = byteaddr*8+bitaddr;
        if(idx < m_allSensorList.size())
        {
            m_allSensorList[idx].m_name = str;
            m_allSensorList[idx].m_type = type;
        }
    }

}

void MultiNeedleRotary::initErrorCodeAndStateList()
{
    m_allErrorCodeAndStateList.clear();

    m_allErrorCodeAndStateList.append(makeAErrorStateItem(0x001D,tr("Not filled with gas")));// 未加气
}

